package com.caoJun.jdbc;


import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @Description: 原生态JDBC 实现数据库的数据的修改
 * @Author 83-start
 * @Time 2021/4/20 15:34
 */
public class JdbcTools {
    /**
     * 驱动类名
      */
    private String dbDriver = "com.mysql.jdbc.Driver";

    /**
     * 连接数据库的字符串
     */
    private String url = "jdbc:mysql://39.108.107.27:3306/dbspring?useUnicode=true&characterEncoding=utf-8";

    //连接数据库对象
    public Connection connection;

    public JdbcTools() {
        try {
            //加载驱动
            Class.forName(dbDriver).newInstance();
            // 连接数据库
            connection = (Connection) DriverManager.getConnection(url, "root", "root");
            System.out.println("======== 连接数据库成功");
        } catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("======== 连接数据库失败");
        }
    }

}
